package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsActionNotTimeout;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.car.viewhelper.CarAutoTerminalManageViewHelper;

/**
 * 特权车管理-初期显示
 * 
 * @author ZhaoQiChao
 */
public class CarAutoTerminalBrandNewCarInputAction extends TmsActionNotTimeout {
	
	private Logger logger = Logger.getLogger(CarAutoTerminalBrandNewCarInputAction.class);
	private static final String BACKFLAG = "backFlag";
	
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		CarAutoTerminalManageViewHelper view = new CarAutoTerminalManageViewHelper();
		if (!StringUtil.isNullOrBlank(uc.getParameter("vin"))
				&& !"1".equals(String.valueOf(uc.getAttribute(BACKFLAG)))) {
			view.setVin(uc.getParameter("vin"));
			uc.removeAttribute(BACKFLAG);
		}
		String dataFlg = request.getParameter("dataFlg");
		if(!StringUtil.isNullOrBlank(dataFlg)
				&& dataFlg.equals("1")) {
			view.setBackFlag(2);
		}
		// “1：查验照相、2：流程受理、18：退办继续受理”
		view.setStatus(request.getParameter("status"));
		request.setAttribute(VIEWHELP, view);	
		
		logger.debug(this.getClass().getName() + "#doAction was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
